-- suicide_attack
-- create by weism
-- 攻击受创（技能规则）

return {
    apply = function(source, target, skillId, round, para, extra)
        -- 威力
        local force = para[2];
        local damage;
        local maxHp = target:queryAttrib(para[1]);

        -- 伤害
        if para[1] == "max_hp" then
            damage = math.modf(maxHp * force / 1000);
        else
            damage = source:getAttack() * math.modf(force / 1000);
        end

        -- 先自杀
        CombatM.doDamage(source, source, source:getHp(), 0, nil, extra);

        -- 对敌人造成伤害
        CombatM.receiveDamage(source, target, damage, skillId, extra);

        -- 增加命中动作
        SkillM.getSequence(target):hit(source, target, skillId);

        -- 作用目标
        return { target, };
    end,

    parse = function(desc)
        local arr = string.explode(desc, ",");
        return { arr[1], tonumber(arr[2]), };
    end,

    -- 解析技能描述
    parseDesc = function(source, skillId, desc, para)
        -- 威力
        local force = para[1];

        -- 2. 攻击方的攻击
        local attack = source:getAttack();

        -- 3. 伤害
        local damage = attack * math.modf(force / 1000);

        desc = string.gsub(desc, "{suicide_attack}", damage);

        -- 系别TODO

        return desc;
    end,
};
